package com.example.demolearn.designPatterns;
// 建造者模式
public class MilkTea {
    private String size;
    private boolean ice;
    private MilkTea(Builder builder){
        this.size = builder.size;
        this.ice = builder.ice;
    }
    public String getSize(){
        return this.size;
    }
    public boolean getIce(){
        return this.ice;
    }
    public static class Builder{
        public String size = "中杯";
        public boolean ice = true;
        // 匿名内部类必须有构造函数  通常情况下是带参的
        public Builder() {

        }
        public void setIce(boolean ice) {
            this.ice = ice;
        }

        public void setSize(String size) {
            this.size = size;
        }
        public MilkTea build(){
            return new MilkTea(this);
        }
    }

}
